import { eLayoutType, RoutesService } from '@abp/ng.core';
import { eIdentityPolicyNames, eIdentityRouteNames } from '@abp/ng.identity/config';
import { eThemeSharedRouteNames } from '@abp/ng.theme.shared';
import { APP_INITIALIZER } from '@angular/core';

export const IDENTITY_ROUTE_PROVIDERS = [
  { provide: APP_INITIALIZER, useFactory: configureRoutes, deps: [RoutesService], multi: true },
];

export function configureRoutes(routes: RoutesService) {
  return () => {
    routes.add([
      {
        path: undefined,
        name: eIdentityRouteNames.IdentityManagement,
        parentName: eThemeSharedRouteNames.Administration,
        requiredPolicy: eIdentityPolicyNames.IdentityManagement,
        iconClass: 'solution',
        layout: eLayoutType.application,
        order: 1,
      },
      {
        path: '/identity/roles',
        name: eIdentityRouteNames.Roles,
        parentName: eIdentityRouteNames.IdentityManagement,
        requiredPolicy: eIdentityPolicyNames.Roles,
        order: 1,
      },
      {
        path: '/identity/user-detail',
        name: eIdentityRouteNames.Users,
        parentName: eIdentityRouteNames.IdentityManagement,
        requiredPolicy: eIdentityPolicyNames.Users,
        order: 2,
      },
      {
        path: '/identity/users',
        name: '用户列表',
        invisible: true,
        parentName: eIdentityRouteNames.IdentityManagement,
        requiredPolicy: eIdentityPolicyNames.Users,
        order: 3,
      },
    ]);
  };
}
